<template>
  <div class="cusNav ">
    <el-menu class="el-menu-vertical-demo" :collapse="isCollapse" :default-active="defaultActive" background-color="#FFFFFF" text-color="#768EA8" active-text-color="#ffffff"
      :router="true">
      <template v-for="(data, index) in navList">
        <template v-if="data.children">
          <el-submenu :index="data.url" :key="index">
            <template slot="title">
              <i class="iconfont" :class="[data.icon]"></i>
              <span>{{ data.name }}</span>
            </template>
            <el-menu-item-group>
              <el-menu-item v-for="(nData, nIndex) in data.children" :index="nData.url" :key="nIndex">
                {{ nData.name }}
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </template>
        <template v-else>
          <el-menu-item :key="index" :index="data.url">
            <i class="iconfont" :class="[data.icon]"></i>
            <span slot="title">{{ data.name }}</span>
          </el-menu-item>
        </template>
      </template>
    </el-menu>
  </div>
</template>
<script>
export default {
  name: "cusNav",
  data() {
    return {
      defaultActive: null,
      tokenId: sessionStorage.getItem('tokenId'),
      BASE_URL: process.env.VUE_APP_BASE_URL,
    }
  },
  props: {
    isCollapse: {
      type: Boolean,
      default: false,
    }
  },
  computed: {
    identity() {
      return this.$store.state.identity
    },
    navList() {
      return this.$store.state.navList
    },
    employeeInfo() {
      return this.$store.state.employeeInfo
    },
  },
  watch: {
    '$route': { // $route可以用引号，也可以不用引号  监听的对象
      handler(to) {
        console.log(to)
        console.log(this.navList)
        this.defaultActive = to.fullPath
      },
      deep: true, // 深度观察监听 设置为 true
      immediate: true, // 第一次初始化渲染就可以监听到
    }
  },
  methods: {
    openCorporationApplyAudit(url) {
      // let responed  = 'SUPERVISORUNIT～91440106MAC6JK3B1U～市云为上大分市云为数据科技有限公司～POE～440106～温俊楠(测试)～15875311244～f0f4ca0b'
      let responedArr = url.split('～');
      let uniqueCode = responedArr[1];
      let corpName = responedArr[2];
      let corpType = responedArr[3];
      let regionId = responedArr[4];
      let workerName = responedArr[5];
      let workerPhoneNumber = responedArr[6];
      let workerUserName = responedArr[7];

      let testUrl = `http://192.168.2.77:9768/web/#/enterpriseLogin?uniqueCode=${uniqueCode}&&corpName=${corpName}&&corpType=${corpType}&&regionId=${regionId}&&workerName=${workerName}&&workerPhoneNumber=${workerPhoneNumber}&&workerUserName=${workerUserName}`
      let proUrl = `http://gzrsj.rsj.gz.gov.cn/vsrcyjgl/web/#/enterpriseLogin?uniqueCode=${uniqueCode}&&corpName=${corpName}&&corpType=${corpType}&&regionId=${regionId}&&workerName=${workerName}&&workerPhoneNumber=${workerPhoneNumber}&&workerUserName=${workerUserName}`
      window.open(this.BASE_URL == '' ? testUrl : proUrl);
    },
    toRoute() {
      window.open(`http://10.196.135.39/vsgzrcyjbys/Desktop.aspx?PATH=rcyj/ywglxsh/ywglysh_list_rcyj&RESID=c82ced53-b2fb-4f3f-817a-2b2ea4e1d582&TOKENID=${this.tokenId}`);
    },
    goDataAnalysis() {
      this.$router.Location('/dataAnalysis')
    },
  },

}
</script>
<style scoped lang="scss">

.iconfont {
  color: #768EA8;
  font-size: 20px;
  margin-right: 10px;
}
::-webkit-scrollbar {
  display: none;
}

.cusNav {
  width: 100%;
  height: 100%;
  overflow: auto;
  border-right: solid 1px #e6e6e6;
  background: #FFFFFF;
}

::v-deep .el-menu {
  border: none;
}

.el-menu-item.is-active {
  background-color: #335A82 !important;
  font-weight: 600;
}

::v-deep.el-menu-item {
  /* 修改为您想要的文字大小 */
  font-size: 14px !important;
}
</style>
<style>

</style>

